<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
    <head>
        <title>合租列表</title>
        <meta charset="UTF-8">
       <base th:href="@{/}">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
                <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.5.0/dist/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
        
 <script src="js/jquery-3.4.1.min.js"></script>
    </head>
    <body>
        <div class="container text-center">
		这是首页
            <a th:href="'users/user_Info/'+${session.sessionuser.Uid}">个人信息</a>&nbsp;
            <a th:href="'users/modifypwd_page/'+${session.sessionuser.Uid}">修改密码</a>&nbsp;
             <a th:href="'cotenancy/publichcotenancy/'+${session.sessionuser.Uid}">发布出租房子</a>&nbsp;&nbsp;
            <div>
            <h1>合租类型</h1>	
    <h3>根据标题搜索</h3>
        
       <form action="findbyHtopic">
                <input type="text" name="Htopickey" placeholder="请输入标题关键字" />&nbsp;
                <button type="submit">查询</button>
            </form>
        <h3>通过价格搜索</h3>
            <form action="findbyHprice">
    <input type="text" name="low" placeholder="请输入最小金额" />&nbsp;--&nbsp;
               <input type="text" name="high" placeholder="请输入最大金额" />
                <button type="submit">查询</button>
                   </form>
             </div>
             <br>
            <table class="table table-hover table-striped">
                <tr>
                	<th>发布人</th>
                    <th>房屋编号</th>
                    <th>意向性别</th>
                    <th>房屋描述</th>
                    <th>房屋地址</th>
                    <th>交通状况</th>
                    <th>房屋类型</th>
                    <th>房屋类型</th>
                    <th>操作</th>
                    	
                </tr>
                    <tr th:each="c:${cotelist}" th:id="|tr${c.Uid}|">
                    	<td th:text="${c.Uid}"></td>
                        <td th:text="${c.Hid}"></td>
                        <td th:text="${c.Hcgender}"></td>
                        <td th:text="${c.Hdes}"></td>
                        <td th:text="${c.Haddress}"></td>
                        <td>[[${c.Htra}]]</td>
                          <td>[[${c.Hcon}]]</td>
                        <td>[[${c.Htype}]]</td>    
                        <td>
                            <a th:href="|javascript:collectCotenancy('${session.sessionuser.Uid}','${c.Uid}','${c.Hid}');|">收藏</a>
                             <a th:href="'cotenancy/cotenancyinfo/'+${c.Uid}+'/'+${c.Hid}">查看详细内容</a>
                      
                       
                       
                        </td>
                    </tr>
            </table>
                         <a class="btn btn-outline-info" th:href="@{'index/'+${session.sessionuser.Uid}}">返回首页</a>&nbsp;
             
            <br>
            <br>
             <script>  
                function collectCotenancy(uid1,uid2,hid) {
                    $.ajax({
                        url: 'cotenancy/collect',
                        type: 'POST',
                        data: {Uid1:uid1,Uid2:uid2,Hid:hid},
                        success: function () {
                            alert("收藏成功!" );
                           
                        },
                        error: function (req, status, error) {
                            alert("收藏失败！" + error);
                        }
                    });
                }
            </script>
        </div>

    </body>
</html>